package cn.jsj.cxsys.controller;

import org.springframework.stereotype.*;
import cn.jsj.cxsys.service.*;
import org.springframework.beans.factory.annotation.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.ArrayList;

import org.springframework.web.bind.annotation.*;
import cn.jsj.cxsys.pojo.*;
import org.springframework.web.multipart.*;

@Controller
@CrossOrigin
@ResponseBody
public class ApkDownLoad
{
    @Autowired
    private ApkDownload apkDownload;

    @RequestMapping(value = { "downloadApk" }, method = { RequestMethod.POST, RequestMethod.GET })
    public void download(final HttpSession session, final HttpServletRequest request, final HttpServletResponse response) throws IOException {
        this.apkDownload.downloadApplication(session, request, response);
    }

    @RequestMapping(value = { "checkVersion" }, method = { RequestMethod.POST, RequestMethod.GET }, params = { "version" })
    public UpdateInformation judgeUpdateInformation(@RequestParam("version") final String version) {
        return this.apkDownload.checkVersion(version);
    }

    @RequestMapping(value = { "uploadApk" }, method = { RequestMethod.POST }, params = { "account", "password", "versionName", "discription" })
    public String upload(@RequestParam("file") final MultipartFile multipartFile, @RequestParam("account") final String account, @RequestParam("password") final String password, @RequestParam("discription") final String discription, @RequestParam("versionName") final String versionName) {
        return this.apkDownload.uploadApplication(multipartFile, account, password, discription, versionName);
    }
}
